package com.xpec.c4.db.secure;

import java.util.Properties;

import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
import org.hibernate.connection.C3P0ConnectionProvider;

/**
 * 自定义的数据库<br>
 * 功能：数据库连接密码解密
 * 
 * @author Bany
 * 
 * @version 创建时间：2008-8-5 上午10:56:36
 * 
 */

public class CustomDriverManagerConnectionProvider extends
		C3P0ConnectionProvider {

	public CustomDriverManagerConnectionProvider() {
		super();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.hibernate.connection.DriverManagerConnectionProvider#configure(java.util.Properties)
	 */
	@Override
	public void configure(Properties props) throws HibernateException {
		String user = props.getProperty(Environment.USER);
		String password = props.getProperty(Environment.PASS);
		props.setProperty(Environment.USER, SecUtil.decrypt(user));
		props.setProperty(Environment.PASS, SecUtil.decrypt(password));
		super.configure(props);
	}

}
